Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix relax_and_split kwargs dict passing #466

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ryanwu4
Copy link

@ryanwu4 ryanwu4 commented Dec 18, 2024

I noticed that the relax_and_split() method in the permanent magnet optimization tools was .pop()'-ing keys such as nuand the regularization terms out ofkwargs`, even though these should actually be passed to the convex MwPGP algorithm in the code block:

algorithm_history, _, _, m = convex_step(
    A_obj=pm_opt.A_obj,
    b_obj=pm_opt.b_obj,
    ATb=ATb,
    m_proxy=np.ascontiguousarray(m_proxy.reshape(pm_opt.ndipoles, 3)),
    m0=np.ascontiguousarray(m.reshape(pm_opt.ndipoles, 3)),  # note updated m is new guess
    m_maxima=mmax,
    **kwargs
)

This causes a bug where if you optimize with relax_and_split(), the default value of nu = 1e100 is used since this key has been removed from the kwargs dict when it is passed on to the convex MwPGP method. This pull request changes it to a get() method for the relevant keys instead.

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.66%. Comparing base (c1183a4) to head (35e7900).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #466   +/-   ##
=======================================
  Coverage   92.66%   92.66%           
=======================================
  Files          78       78           
  Lines       14514    14514           
=======================================
  Hits        13450    13450           
  Misses       1064     1064           
Flag Coverage Δ
unittests 92.66% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@landreman landreman requested a review from akaptano January 29, 2025 11:33
@landreman
Copy link
Contributor

@akaptano Is this change ok with you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants